#ifndef STATISTICSPAGE_H
#define STATISTICSPAGE_H
#include <QObject>
#include <QWidget>
#include <QTcpSocket>
#include <QJsonObject>
#include <QVBoxLayout>
#include <QPushButton>
#include <QDateEdit>
#include <QtCharts/QChartView>
namespace Ui {
class StatisticsPage;
}

class StatisticsPage : public QWidget
{
    Q_OBJECT

public:
    explicit StatisticsPage(QWidget *parent = nullptr,QTcpSocket* externalSocket = nullptr);
    ~StatisticsPage();
    void exportToExcel();
public slots:
    void handleServerMessage(const QJsonObject& json);
    void onRefreshClicked();
    void onQueryButtonClicked();
    void handleCurrentStatistic(const QJsonObject& json);
    void handlePreviousStatistic(const QJsonObject& json);
    void onExportClicked();
private:
    Ui::StatisticsPage *ui;
    QTcpSocket* socket;
    QVBoxLayout* layout;
    QPushButton* refreshButton;
    QWidget* chartContainer;
    QVBoxLayout* chartLayout;
    QPushButton* queryButton;
    QDateEdit* dateEdit;
    QPushButton* exportButton;
    QString stat_date;
    QString entry_count;
    QString exit_count;
    QString total_income;
    QString usage_rate;
    QString reservation_cnt;
    QString reservation_rt;

};

#endif // STATISTICSPAGE_H
